package com.msconfig.mvp.view.fragment;

/*
 * author: caojunhao
 * date  : 2020/4/28
 * desc  :
 */

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.geo.msconfig.R;
import com.msconfig.device.DeviceManage;
import com.msconfig.event.NullEvent;
import com.msconfig.io.ConnectListener;
import com.msconfig.mvp.view.activity.base.BaseMvpActivity;
import com.msconfig.mvp.view.activity.base.BaseMvpFragment;
import com.msconfig.mvp.view.activity.base.BasePresenter;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.List;

public class SatellitePageFragment extends BaseMvpFragment implements View.OnClickListener {
    private LinearLayout llSatelliteLocateInformation;
    private LinearLayout llSatelliteForm;
    private LinearLayout llSatelliteMap;

    public static SatellitePageFragment newInstance() {
        Bundle args = new Bundle();
        SatellitePageFragment fragment = new SatellitePageFragment();
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    protected int getLayoutId() {
        return R.layout.layout_fragment_satellite;
    }

    @Override
    protected void initView(View view) {
        llSatelliteLocateInformation =view.findViewById(R.id.ll_satellite_locate_information);
        llSatelliteForm =view.findViewById(R.id.ll_satellite_form);
        llSatelliteMap =view.findViewById(R.id.ll_satellite_map);
    }


    @Override
    protected void initListener(View view) {
        llSatelliteLocateInformation.setOnClickListener(this);
        llSatelliteForm.setOnClickListener(this);
        llSatelliteMap.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    //目前这里只是为了实现eventbus
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void haveNull(NullEvent event) {
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ll_satellite_locate_information:
                if(!DeviceManage.getInstance().isConnected()){
                    Toast.makeText(getContext(),R.string.toast_none_connect, Toast.LENGTH_SHORT).show();
                    return;
                }
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SatelliteLocateInformationFragment.newInstance());
                break;
            case R.id.ll_satellite_form:
                if(!DeviceManage.getInstance().isConnected()){
                    Toast.makeText(getContext(),R.string.toast_none_connect, Toast.LENGTH_SHORT).show();
                    return;
                }
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SatelliteFormFragment.newInstance());
                break;
            case R.id.ll_satellite_map:
                if(!DeviceManage.getInstance().isConnected()){
                    Toast.makeText(getContext(),R.string.toast_none_connect, Toast.LENGTH_SHORT).show();
                    return;
                }
                ((BaseMvpActivity)getActivity()).goToNextFragment(this, SatelliteMapFragment.newInstance());
                break;
        }
    }

    @Override
    protected void createPresenter(List<BasePresenter> mPresenters) {

    }
}
